package com.hksj.Intelligentmanagement.mqtt.command;

import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
public class ConnMsgData extends BaseMsgData{
    public ConnMsgData() {
         setCmd(CommandConstant.COMMAND_CONN);
    }

    private Integer devices_num;
    private List<DeviceInfo> devices;
    private String le_upd_req = "03";
    private Integer le_upd_delay = 6;
    private ConnParams conn_params = new ConnParams();
    private ConnPhys conn_phys = new ConnPhys();
    private Integer keep_time = 0;
    private Integer notify_chars_num = 1;
    private List notify_chars = Arrays.asList(new NotifyChar());
    private Integer indicate_chars_num = 0;
    private List indicate_chars = new ArrayList();
    private Integer send_num = 0;

    @Data
    public static class DeviceInfo{
        private String addr;
    }

    @Data
    public static class ConnParams{
        private Boolean reject = true;
        private Integer gap_min = 20;
        private Integer gap_max = 30;
        private Integer slave_latency = 0;
        private Integer conn_sup_timeout = 2000;
    }

    @Data
    public static class ConnPhys{
        private String phys_tx = "2M";
        private String phys_rx = "2M";
    }

    @Data
    public static class NotifyChar{
        private Integer handle = 16;
        private Integer cccd = 17;
    }

    public DeviceInfo createDeviceInfo(String addr){
        DeviceInfo deviceInfo = new DeviceInfo();
        deviceInfo.setAddr(addr);
        return deviceInfo;
    }
}
